﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

//13.喝多少瓶汽⽔

int main()
{
	int n = 0;
	scanf("%d", &n);
	int sum = 0;
	int empty = 0;
	sum += n;
	empty += n;
	while (empty >= 2)
	{
		sum += empty / 2;
		empty = empty / 2 + empty % 2;
	}
	printf("%d", sum);
	return 0;
}
//方法2：
int main()
{
	int n = 0;
	scanf("%d", &n);
	int sum = 0;
	int empty = 0;
	if (n == 0)
	{
		sum = 0;
	}
	else
	{
		sum += 2 * n - 1;
	}
	printf("%d", sum);
	return 0;
}


//14.字符转换
//方法1：
int main()
{
	char arr[31] = { 0 };
	int i = 0;
	scanf("%s", arr);
	for (i = 0; i < 32; i++)
	{
		if (arr[i] >= 'a' && arr[i] <= 'z')
		{
			arr[i] -= 32;
		}
		else if (arr[i] >= 'A' && arr[i] <= "Z")
		{
			arr[i] += 32;
		}
	}
	printf("%s", arr);
	return 0;
}
//方法2（库函数法）：
#include <ctype.h>
int main()
{
	char arr[31] = { 0 };
	int i = 0;
	scanf("%s", arr);
	while (arr[i])
	{
		if (islower(arr[i]))            //islower()：判断字符是否为⼩写字⺟
		{
			arr[i] = toupper(arr[i]);   //toupper()：将字符转换为⼤写字⺟
		}
		else if (isupper(arr[i]))       //isupper()：判断字符是否为⼤写字⺟
		{
			arr[i] = tolower(arr[i]);   //tolower()：将字符转换为⼩写字⺟
		}
		i++;
	}
	printf("%s", arr);
	return 0;
}


//15.交换两个整数
void Swap(int* a, int* b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
int main()
{
	int a = 0, b = 0;
	scanf("%d %d", &a, &b);
	printf("a = %d  b = %d\n", a, b);
	Swap(&a, &b);
	printf("a = %d  b = %d\n", a, b);
	return 0;
}


//16.求两个整数的平均值
//数字太大会溢出
int average1(int m, int n)
{
	return (m + n) / 2;
}
//改进：
int average2(int m, int n)
{
	return m + (n - m) / 2;
}
int main()
{
	int m = 0, n = 0;
	scanf("%d %d", &m, &n);
	int ret = average1(m, n);
	return 0;
}


//17.求字符串⻓度
int My_Strlen(char* arr)
{
	int count = 0;
	while (*arr)
	{
		count++;

		arr++;
	}
	return count;
}
int main()
{
	char arr[31] = { 0 };
	scanf("%s", arr);
	int len = My_Strlen(arr);
	printf("%d", len);
	return 0;
}


